PC = $(ORACLE_HOME)/bin/proc
CC = g++
LINKER = g++
CCLIB = g++

.SUFFIXES: .pcpp .cpp .o

PROC_INCL= include=$(ORACLE_HOME)/precomp/public \
		include=$(ORACLE_HOME)/plsql/include \
                include=/usr/include

LIBDIRS= -L$(ORACLE_HOME)/lib 
INCL=-I$(ORACLE_HOME)/precomp/public/  -I"../incl/" -I"../incl/proc/" 
LIB= -lm -lclntsh 

VERSION=V1.0

RM = rm -f

H010_db_merge=H010_db_merge.$(VERSION)

OBJ = connectiong.o connection.o exception.o command.o reader.o row.o readerimp.o readerimpsingle.o \
	pubfunc.o datetime.o str.o tableschema.o tablemapping.o config.o load.o append.o truncate.o merge.o wrapper.o main.o
	
all: $(H010_db_merge) clean

$(H010_db_merge): $(OBJ)
	$(LINKER) -o $(H010_db_merge) $(LIBDIRS) $(OBJ) $(LIB) 
	mv $@ ~/bin

VPATH=proc

#%.o:%.pcpp
.pcpp.o:
	$(PC) iname=$<  oname=$(subst .pcpp,,$<).cpp MODE=ORACLE CODE=CPP  ${PROC_INCL} parse=none \
	SQLCHECK=NONE CHAR_MAP=VARCHAR2 SQLCHECK=syntax
	$(CC) -D_ORACLE_ORACA -c $(INCL) $(subst .pcpp,,$<).cpp -o $@
	$(RM) $(subst .pcpp,,$<).cpp

#%.o:%.cpp
.cpp.o:
	$(CC) -c $(INCL) $< -o $@ $(CXXFLAGS) $(CFLAGS)

#%.o:%.pc
.pc.o:
	$(PC) iname=$<  oname=$(subst .pcpp,,$<).cpp MODE=ORACLE CODE=CPP  ${PROC_INCL} parse=none \
	SQLCHECK=NONE CHAR_MAP=VARCHAR2 SQLCHECK=syntax 
	$(CC) -c $(INCL) $(subst .pcpp,,$<).cpp -o $@
	$(RM) $(subst .pcpp,,$<).cpp
	
clean:
	@$(RM) *.o *.lis tp* src/proc/*.lis
